package com.mrper.util.share;

import android.content.Context;

import com.miguo.framework.view.LoadingDialog;
import com.miguo.ui.R;
import com.miguo.view.listener.ShareListener;
import com.mrper.util.DialogUtil;
import com.mrper.util.ToastUtil;

/**
 * Created by Administrator on 2016/8/26.
 * 分享回调函数
 */

public class ShareCallback implements ShareListener {

    private Context context;
    private LoadingDialog shareLoadingDialog;

    public ShareCallback(Context context){
        this.context = context;
    }

    public void setLoadingDialog(LoadingDialog shareLoadingDialog){
        this.shareLoadingDialog = shareLoadingDialog;
    }

    public LoadingDialog getLoadingDialog(){
        return this.shareLoadingDialog;
    }

    @Override
    public void onComplete() {
        onOperateFinished();
        ToastUtil.showShortToast(context, R.string.activity_goodsDetail_shareCompeleted);
    }

    @Override
    public void onCancel() {
        onOperateFinished();
        ToastUtil.showShortToast(context,R.string.activity_goodsDetail_shareCancel);
    }

    @Override
    public void onError() {
        onOperateFinished();
        ToastUtil.showShortToast(context,R.string.activity_goodsDetail_shareFailed);
    }

    private void onOperateFinished(){
        DialogUtil.hideDialog(shareLoadingDialog,false);
    }

}